classdef NewtonRaphsonMethod
    properties
    end
    methods
        function Solution = Run(obj, MaxIterations, InitialGuess, Func, ...
            Dims)           
            Solution = InitialGuess;
            for i =1 : MaxIterations, 
                f = feval(Func, Solution);
                g = ComputeGradient(Func, Solution);
                Solution = Solution - (f ./g );    
            end
        end
        
        function Solution = RunWithBoundaryConstraints(obj, MaxIterations, ...
                InitialGuess, Func, Min, Max, Dims)           
            Solution = InitialGuess;
            for i =1 : MaxIterations, 
                f = feval(Func, Solution);
                g = ComputeGradient(Func, Solution);
                Solution = Solution - (f ./g );    
                if Solution > Max || Solution < Min
                    Solution = Solution + (f ./g );    
                end
               
            end 
        end
    end
end


